/**
 * Prime Number Sum Calculator
 */

const isPrime = num => {
  if (num < 2) return false;
  for (let i = 2; i <= Math.floor(num**0.5); i++) {
    if (i !== num && num % i === 0) return false;
  }
  return true;
}


const sumPrimes = num => {
  if (num < 2) return 0;
  const primes = [];
  for (let i = 2; i <= num; i++){
    if (isPrime(i)) primes.push(i);
  }
  return primes.reduce(
    (acc, cur) => acc + cur, 0
  )
}

console.log(sumPrimes(2));